\name{TeXPrint}
\alias{TeXPrint}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{Create TeX Code for a Matrix}
\description{This little function just helps create the TeX code for a matrix from an R data object as long as there is an \code{as.data.frame} method for it.}
\usage{
TeXPrint(dat, digits = FALSE)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
  \item{dat}{The data to be converted to TeX style code.
}
  \item{digits}{How many digits should the data be rounded to prior to printing?
}
}
\details{This is a very simple little function and does not do anything fancy.  My main use was to help when working on statistics homeworks or slides.  Dr. Frank Harrell's package, \pkg{Hmisc} has much more elaborate functions for outputing to TeX.}
\value{None.  Called for its side effect of printing a very simple TeX representation of an R data object.
}
%\references{}
\author{Joshua Wiley, \url{http://joshuawiley.com/}}
%\note{}
%\seealso{}
\examples{
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function(dat, digits = FALSE) {
  f <- function(x) {
    paste(x, collapse = " & ")
  }

  if (digits) {
    dat <- as.data.frame(dat, stringsAsFactors = FALSE)
    dat <- as.data.frame(lapply(X = dat, FUN = function(x) {
      if (isTRUE(is.numeric(x))) {
        round(x, digits = digits)
      } else x
    }))
  }

  tmp <- apply(X = dat, MARGIN = 1, FUN = f)
  cat(tmp, sep = " \\\\ \n")
  }
}
% Add one or more standard keywords, see file 'KEYWORDS' in the
% R documentation directory.
\keyword{misc}
